package com.agent.utils;

import java.time.LocalTime;
import java.util.HashMap;
import java.util.Map;

public class TimeConverter {

    private static final Map<String, LocalTime[]> TIME_MAP = new HashMap<>();
    
    static {
        // 初始化节次与时间对应关系

        // 常用节次
        TIME_MAP.put("1-2", new LocalTime[]{LocalTime.of(8, 30), LocalTime.of(9, 55)});
        TIME_MAP.put("3-4", new LocalTime[]{LocalTime.of(10, 15), LocalTime.of(11, 40)});
        TIME_MAP.put("5-6", new LocalTime[]{LocalTime.of(14, 0), LocalTime.of(15, 25)});
        TIME_MAP.put("7-8", new LocalTime[]{LocalTime.of(15, 30), LocalTime.of(16, 55)});
        TIME_MAP.put("9-10", new LocalTime[]{LocalTime.of(19, 0), LocalTime.of(20, 25)});
        TIME_MAP.put("9-11", new LocalTime[]{LocalTime.of(19, 0), LocalTime.of(21, 10)});
        // 单节课
        TIME_MAP.put("1-1", new LocalTime[]{LocalTime.of(8, 30), LocalTime.of(9, 10)});
        TIME_MAP.put("2-2", new LocalTime[]{LocalTime.of(9, 15), LocalTime.of(9, 55)});
        TIME_MAP.put("3-3", new LocalTime[]{LocalTime.of(10, 15), LocalTime.of(10, 55)});
        TIME_MAP.put("4-4", new LocalTime[]{LocalTime.of(11, 0), LocalTime.of(11, 40)});
        TIME_MAP.put("5-5", new LocalTime[]{LocalTime.of(14, 0), LocalTime.of(14, 40)});
        TIME_MAP.put("6-6", new LocalTime[]{LocalTime.of(14, 45), LocalTime.of(15, 25)});
        TIME_MAP.put("7-7", new LocalTime[]{LocalTime.of(15, 30), LocalTime.of(16, 10)});
        TIME_MAP.put("8-8", new LocalTime[]{LocalTime.of(16, 15), LocalTime.of(16, 55)});
        TIME_MAP.put("9-9", new LocalTime[]{LocalTime.of(19, 0), LocalTime.of(19, 40)});
        TIME_MAP.put("10-10", new LocalTime[]{LocalTime.of(19, 45), LocalTime.of(20, 25)});
        TIME_MAP.put("11-11", new LocalTime[]{LocalTime.of(20, 30), LocalTime.of(21, 10)});

    }
    
    public static LocalTime[] convertPeriodToTime(String period) {
        return TIME_MAP.getOrDefault(period, new LocalTime[]{LocalTime.MIN, LocalTime.MIN});
    }
    
    public static int convertDayToNumber(String day) {
        Map<String, Integer> dayMap = new HashMap<>();
        dayMap.put("星期一", 1);
        dayMap.put("星期二", 2);
        dayMap.put("星期三", 3);
        dayMap.put("星期四", 4);
        dayMap.put("星期五", 5);
        dayMap.put("星期六", 6);
        dayMap.put("星期日", 7);
        
        return dayMap.getOrDefault(day, 0);
    }
}